package com.ssy.lingxi.platform.manage.constant;


import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 资讯 - 推荐标签 - enum
 * @author fhj
 * @date 2021/04/26
 * @version 2.0.0
 */
public enum RecommendLabelEnum {

    HEADLINE_ARTICLES(1, "头条文章"),
    SLIDESHOW_NEWS(2, "轮播新闻"),
    IMG_NEWS(3, "图片新闻"),
    RECOMMENDED_READING(4, "推荐阅读"),
    MARKET_RECOMMENDED(5, "行情推荐"),
    THIS_RECOMMENDED(6, "本栏推荐"),
    INVALID_STATE(7, "无效状态");

    private final Integer code;

    RecommendLabelEnum(Integer code, String message) {
        this.code = code;
    }

    /**
     * 根据code获取message
     * */
    public static String getMessage(Integer code) {
        String key = RecommendLabelEnum.class.getSimpleName().concat(".");
        RecommendLabelEnum recommendLabelEnum = Arrays.stream(RecommendLabelEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return recommendLabelEnum != null ? recommendLabelEnum.getMessage() : key.concat(String.valueOf(RecommendLabelEnum.INVALID_STATE.getCode()));
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(),this.code);
    }
}
